*
* Table 8: Program characteristics and dominated choices: heterogeneity
*
* Input table: 
*	"${data_program_level_tidy}"
*
* Output file: 
*	/results/Table8.tex
*

use "${data_program_level_tidy}", clear

gen GPA11_low = GPA11_std <= 0 & GPA11_missing == 0
gen GPA11_high = GPA11_std > 0 & GPA11_missing == 0

qui reghdfe dominated_choice priority_score_cutoff_std priority_score_cutoff_missing ba full_time capital_program ///
	county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year if disadv == 1, absorb(i.id) vce(robust)
est store est1

qui reghdfe dominated_choice priority_score_cutoff_std priority_score_cutoff_missing ba full_time capital_program ///
	county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year if disadv == 0, absorb(i.id) vce(robust)
est store est2

qui reghdfe dominated_choice priority_score_cutoff_std priority_score_cutoff_missing ba full_time capital_program ///
	county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year if GPA11_low == 1, absorb(i.id) vce(robust)
est store est3

qui reghdfe dominated_choice priority_score_cutoff_std priority_score_cutoff_missing ba full_time capital_program ///
	county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year if GPA11_high == 1, absorb(i.id) vce(robust)
est store est4

esttab est1 est2 est3 est4 ///
	using "${result_dir}/Table7.tex", ///
	drop(_cons *_missing) b(4) se(4) r2 indicate("Year FE = *year") ///
	stat(r2, fmt(%18.2g) ///
	labels("R-squared")) ///
	label star(* 0.10 ** 0.05 *** 0.01) replace noomitted nogaps f noobs ///
	nomtitles nonumbers nolines ///
	order(priority_score_cutoff_std priority_score_cutoff_missing ba full_time ///
		capital_program county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15)

* ------------------------------------------------------------------------------	
* Table notes:
count
local n_obs = r(N)
by id, sort: gen nvals = _n == 1 
count if nvals
local n_rols = r(N)
drop nvals
di "The number of applications is " `n_obs' " , which corresponds to " `n_rols' " ROLs."

qui sum dominated_choice
di "The share of dominated choices (on the application-level) is " round(r(mean)*100, 0.01) " percent in this sample."
